package itsos.service.impl;

import itsos.model.*;
import itsos.service.*;
import itsos.dao.*;

import java.sql.Timestamp;
import java.util.*;

import javax.servlet.http.*;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import itsos.common.*;



public class IssueCommentServiceImpl implements IssueCommentService {

	private IssueCommentDao commentDao;
	
	public void setIssueCommentDao(IssueCommentDao commentDao) {
		this.commentDao = commentDao;
	}

	public void deleteComment(HttpServletRequest request, HttpSession session) {
		
		IssueComment comment = new IssueComment();
		comment.setCommentID(new Long(Long.parseLong(request.getParameter("commentID"))));
		comment.setUpdateTime(new Timestamp(System.currentTimeMillis()));
		comment.setUpdateUserID((Long)session.getAttribute("memberID"));
		comment.setDeleteFlag(request.getParameter("deleteFlag"));
		
		commentDao.deleteIssueComment(comment);
		
	}

	public void insertComment(HttpServletRequest request) {
		
		IssueComment comment = new IssueComment();
		comment.setIssueID(new Long(Long.parseLong(request.getParameter("issueID"))));
		HttpSession session = request.getSession();
		
		comment.setComment(request.getParameter("comment"));
		comment.setDeleteFlag("N");
		comment.setInsertTime(new Timestamp(System.currentTimeMillis()));
		comment.setInsertUserID((Long)session.getAttribute("memberID"));
		comment.setUpdateTime(comment.getInsertTime());
		comment.setUpdateUserID(comment.getInsertUserID());
		
		commentDao.insertCommentBox(comment);
	
	}

	public List viewComment(HttpServletRequest request) {
		
		 
		IssueComment comment = new IssueComment();
		
		comment.setIssueID(new Long(Long.parseLong(request.getParameter("issueID"))));
		
		List list = commentDao.getIssueComment(comment.getIssueID());
		
		return list;
	}

}
